package cn.edu.zut.curriculum.controller;

import cn.edu.zut.curriculum.entity.User;
import cn.edu.zut.curriculum.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

@Controller
public class indexController {
    @Autowired
    IUserService iUserService;
    @RequestMapping("/")
    public ModelAndView index(ModelAndView mav){
        mav.setViewName("/User/login");
        return mav;
    }
    @GetMapping("/login")
    public ModelAndView login(ModelAndView mav){
        mav.setViewName("/User/login");
        return mav;
    }
    @GetMapping("/register")  //使用getmapping，管理网址get跳转
    public ModelAndView registerIndex(ModelAndView mav){
        mav.setViewName("/User/register");
        return mav;

    }
    @GetMapping("/publish")        //接收发布商品超链接跳转
    public ModelAndView skip(ModelAndView mav, @RequestParam("uid") long uid){

        System.out.println("id is:"+uid);

        User user=iUserService.select(uid);
        mav.addObject("user",user);
        mav.setViewName("/User/publish");   //发布商品
        return mav;
    }






    @GetMapping("/list")       //接收首页超链接跳转
    public ModelAndView skip5(ModelAndView mav,@RequestParam("uid") long uid){
        User user=iUserService.select(uid);
        mav.addObject("user",user);
        mav.setViewName("/User/list");
        return mav;
    }
/*
    @GetMapping("/commonlist")   //接收订单超链接跳转
    public ModelAndView skip6(ModelAndView mav){
        mav.setViewName("/User/commonlist");
        return mav;
    }


   @GetMapping("/login2")  //使用getmapping，管理网址get跳转
    public ModelAndView loginIndex(ModelAndView mav){
        mav.setViewName("/AdministratorMapper/login2");
        return mav;

    }
*/
}
